package com.wjc.aop;


import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.springframework.stereotype.Component;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

@Component
@Aspect
public class TimerAspect {

    //在环绕增强中，我们可以给定一个参数，代表我们要获取处理切入的点
    //改包下的*类*方法**参数
    @Around("execution(* com.wjc.service.Impl.*.*(..))")
    public Object around(ProceedingJoinPoint jp) throws Throwable {
   //     System.out.println("环绕前");
   //     System.out.println("签名:"+jp.getSignature());

        long start=System.currentTimeMillis();
        //执行目标方法proceed
        Object proceed = jp.proceed();
       // System.out.println("环绕后");
        //System.out.println(proceed);
        long end=System.currentTimeMillis();
        System.out.println(jp.getSignature().getName()+"耗时:"+(end-start)+"ms");
        return  proceed;
    }
}
